// Author: Domien Nowicki

#ifndef VERSUSGAME_H
#define VERSUSGAME_H

#include "Game.h"
#include "Map.h"
#include "Player.h"
#include "Clock.h"
#include "Highscore.h"

class VersusGame: public Game
{
public:
	enum Turn { HUMAN, COMPUTER };

	// Constructors
	VersusGame(const Map& map, const Properties& properties, Highscore& highscore);

	// Destructor
	virtual ~VersusGame();

	// Overloaded operations a game can do	
	virtual void Start();
	virtual void Stop();

	// Help for the player
	virtual void Hint();


protected:
	// Operation when game ended
	virtual void EndGame(const Player *player);

	// Turn based operations
	virtual void SwitchTurn();
	virtual void DoTurn();

	// Operation when clock timed out
	virtual void Timeout();

	// Show/get information to the user
	virtual bool GetName(std::string *name) = 0;
	virtual void ShowHighscore(const Highscore& highscore) = 0;

	// Overloaded new components allocation
	virtual Player* NewHumanPlayer(Map* map) = 0;
	virtual Map* NewMap(const Map& map) = 0;
	virtual Clock* NewClock(Clock::ClockType type) = 0;

	// Get the running time
	int GetTime() const;

	// Interface to computer and human player
	Player* humanPlayer;
	Player* computerPlayer;

private:
	//Helper functions
	const Highscore& GetHighscore();
	void Clear();
	void SetHintPenalty(int penalty);

	const Map* map;
	Map* humanMap;
	Map* computerMap;
	Clock *clock;
	Highscore *highscore;
	Turn turn;
	int hintPenalty;

	static const unsigned int MAXTURNTIME = 15;
	static const int HINTPENALTY = 2;

};

#endif //VERSUSGAME_H